{extend name='public/base' /}
{block name='content'}
{include file='public/content_header' /}
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <!-- 表单头部 -->
                <div class="card-header">
                    <div class="btn-group">
                        <a class="btn flat btn-sm btn-default BackButton">
                            <i class="fas fa-arrow-left"></i>
                            返回
                        </a>
                    </div>
                </div>
                <!-- 表单 -->
                <form id="dataForm" class="form-horizontal dataForm" action="" method="post" enctype="multipart/form-data">
                    <!-- 表单字段区域 -->
                    <div class="card-body">
                        <div class="form-group row rowText">
    <label for="title" class="col-sm-2 col-form-label">标题</label>
    <div class="col-sm-10 col-md-4 formInputDiv">
        <input id="title" name="title" value="{$data.title|default=''}" placeholder="请输入标题" type="text" class="form-control fieldText">
    </div>
</div>
<div class="form-group row rowSelect">
    <label for="cate_id" class="col-sm-2 col-form-label">行业分类</label>
    <div class="col-sm-10 col-md-4 formInputDiv">
        <select name="cate_id" id="cate_id" class="form-control select2bs4 fieldSelect" data-placeholder="请选择分类">
            <option value=""></option>
            {foreach name='cate_list' id='item'}
    <option value="{$item.id}" {if isset($data) && $data.cate_id==$item.id}selected{/if}>
        {$item.name}
    </option>
{/foreach}
        </select>
    </div>

    <script>
        $('#cate_id').select2({
            theme: 'bootstrap4'
        });
    </script>
</div>
<div class="form-group row rowEditor">
    <label for="content" class="col-sm-2 col-form-label">内容</label>
        <div class="col-sm-10">
            <div id="contentEditor">{$data.content|raw|default='<p></p>'}</div>
            <textarea id="content" name="content" style="display: none">{$data.content|raw|default=''}</textarea>
        </div>
    <script>
        var E = E||window.wangEditor;
        if(editor_content!==undefined){
            editor_content.destroy();
        }
        var editor_content = new E('#contentEditor');
        editor_content.config.zIndex=1000;
        editor_content.config.uploadImgServer = editorUploadUrl;
        editor_content.config.uploadFileName = 'file';
        editor_content.create();
        editor_content.config.onchange = function (newHtml) {
            $('#content').val(newHtml);
        };
</script>
</div>

<div class="form-group row">
                            <label class="col-sm-2 col-form-label ">采购清单</label>
                            <div class="col-sm-10 col-md-10">
                                <table id="settingSetting" class="table table-hover table-bordered datatable"
                                       width="100%">
                                    <thead>
                                    <tr class="input-type">
                                        
                                        <th>名称</th>
                                        <th>规格</th>
                                        <th>单位</th>
                                        
                                        <th>数量</th>
                                        <th>最高报价</th>
                                    </tr>
                                    </thead>
                                    <tbody id="dataBody">
                                    {if isset($compute)}
                                    {foreach name='compute' id='item'}
                                    <tr>
                                        

                                        

                                        <td>
                                            <input class="form-control" placeholder="名称" value="{$item.type|default=''}"
                                                   maxlength="50"   name="config_name[]" readonly>
                                            
                                        </td>
                                        <td>
                                            <input class="form-control" placeholder="规格" value="{$item.spec|default=''}"
                                                   maxlength="50"   name="config_spec[]" readonly>
                                            
                                        </td>
                                        <td>
                                            <input class="form-control" placeholder="单位" value="{$item.brand|default=''}"
                                                   maxlength="50"   name="config_brand[]" readonly>
                                            
                                        </td>
                                        <td>
                                            <input class="form-control" placeholder="数量" value="{$item.all_num|default=''}"
                                                   maxlength="50"   name="config_num[]" readonly>
                                            <input type="hidden" name="config_compute_id[]" value="{$item.compute_id|default=''}">
                                        </td>
                                        <td>
                                           <input class="form-control" placeholder="最高报价" value="{$item.price|default=''}"
                                                   maxlength="50"   name="config_price[]">

                                        </td>
                                        
                                    </tr>
                                    {/foreach}
                                    {/if}
                                    </tbody>
                                </table>
                            </div>
                        </div>


<div class="form-group row rowDatetime">
    <label for="start_time" class="col-sm-2 col-form-label">开始时间</label>
    <div class="col-sm-10 col-md-4 formInputDiv">
        <input id="start_time" readonly name="start_time" value="{$data.start_time|default=''}" placeholder="请选择开始时间" type="text" class="form-control filedDatetime">
    </div>
    <script>
        laydate.render({
            elem: '#start_time',
            type: 'datetime',
        });
    </script>
</div>

<div class="form-group row rowNumber">
    <label for="sort" class="col-sm-2 col-form-label">排序</label>
    <div class="col-sm-10 col-md-4 formInputDiv">
         <div class="input-group">
            <input id="sort" name="sort" value="{$data.sort|default='0'}" placeholder="请输入排序" type="number" class="form-control fieldNumber">
        </div>
    </div>

    <script>
        $('#sort')
            .bootstrapNumber({
                upClass: 'success',
                downClass: 'primary',
                center: true
            });
    </script>
</div>
<div class="form-group row rowSelect">
    <label for="win" class="col-sm-2 col-form-label">中标名次</label>
    <div class="col-sm-10 col-md-4 formInputDiv">
        <select name="win" id="win" class="form-control select2bs4 fieldSelect" data-placeholder="请选择中标名次">
            <option value=""></option>
                    {foreach win_list as $key=>$value}
        <option value="{$key}" {if isset($data) && $data.win==$key}selected{/if}>{$value}</option>
        {/foreach}



        </select>
    </div>

    <script>
        $('#win').select2({
            theme: 'bootstrap4'
        });
    </script>
</div>
<div class="form-group row rowSelect">
    <label for="status" class="col-sm-2 col-form-label">状态</label>
    <div class="col-sm-10 col-md-4 formInputDiv">
        <select name="status" id="status" class="form-control select2bs4 fieldSelect" data-placeholder="请选择状态">
            <option value=""></option>
                    {foreach status_list as $key=>$value}
        <option value="{$key}" {if isset($data) && $data.status==$key}selected{/if}>{$value}</option>
        {/foreach}



        </select>
    </div>

    <script>
        $('#status').select2({
            theme: 'bootstrap4'
        });
    </script>
</div>

                    </div>
                    <!-- 表单底部 -->
                    <div class="card-footer">
                        <div class="row">
                            <div class="col-sm-2">
                            </div>

                            <div class="col-sm-10 col-md-4 formInputDiv">

                                <div class="btn-group">
                                    <button type="submit" class="btn btn-sm btn-primary dataFormSubmit">
                                        保 存
                                    </button>
                                </div>
                                <div class="btn-group">
                                    <button type="reset" class="btn btn-sm btn-default dataFormReset">
                                        重 置
                                    </button>
                                </div>

                                {if !isset($data)}
                                <div class="btn-group float-right createContinueDiv">
                                    <input type="checkbox" class="form-check-input" value="1" id="_create" name="_create" title="继续添加数据">
                                    <label class="form-check-label" for="_create">继续添加</label>
                                </div>
                                {/if}
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>


<script>
    /** 表单验证 **/
    $('#dataForm').validate({
        rules: {
                'title': {
                required: true,

    },
    'cate_id': {
                required: true,

    },
    'content': {
                required: true,

    },
    
    'start_time': {
                required: true,

    },
    'sort': {
                required: true,
        number: true,

    },
    'status': {
                required: true,

    },

        },
        messages: {
                'title': {
               required: "标题不能为空",

    },
    'cate_id': {
               required: "分类不能为空",

    },
    'content': {
               required: "内容不能为空",

    },
    
    'start_time': {
               required: "开始时间不能为空",

    },
    'sort': {
               required: "排序不能为空",
        number: "排序必须为纯数字",

    },
    'status': {
               required: "状态不能为空",

    },

        }
    });
</script>

{/block}